//
//  SAUserInfoTool.m
//  Saas
//
//  Created by bing on 2020/5/28.
//  Copyright © 2020 bing. All rights reserved.
//

#import "SAUserInfoTool.h"
#import "SAUserInfo.h"

//用户信息路径
#define UserInformationPath [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0] stringByAppendingPathComponent:@"user.plist"]


@implementation SAUserInfoTool

//保存
+ (void)saveModel:(SAUserInfo*)model{
    
    //保存用户信息
    [NSKeyedArchiver archiveRootObject:model toFile:UserInformationPath];
    
    
}

//获取
+ (SAUserInfo*)getModel{

    return [NSKeyedUnarchiver  unarchiveObjectWithFile:UserInformationPath];

}

//删除
+ (void)deleteModel{
    
    //删除归档文件
    NSFileManager *defaultManager = [NSFileManager defaultManager];
    if ([defaultManager isDeletableFileAtPath:UserInformationPath]) {
        [defaultManager removeItemAtPath:UserInformationPath error:nil];
    }
    
}


@end
